#!/usr/bin/env bash
# shellcheck disable=SC2091
hostName=$1 || $(hostname)
cd ~ || exit 1
echo "---- 安装 git ..."
command -v git || yum install -y git

echo "---- 安装 n ..."
curl -Lk https://bit.ly/n-install | bash

echo "---- 安装 fish ..."
wget --no-check-certificate -P /etc/yum.repos.d/ https://download.opensuse.org/repositories/shells:fish:release:3/CentOS_7/shells:fish:release:3.repo
yum install -y fish
echo $(which fish) | sudo tee -a /etc/shells
echo -e "sudo hostname $hostName" >> ~/.config/fish/config.fish

echo "---- 安装 Vim ..."
command -v vim || yum -y install vim

echo "---- 安装 Vim 插件管理器 ..."
[[ -f ~/.vim/autoload/plug.vim ]] || curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

echo "---- 复制 Vim vimrc ..."
[[ -f ~/.vimrc ]] || curl 'https://gitee.com/cn-src/script/raw/main/.vimrc' -o ~/.vimrc

echo "---- 安装 Docker ..."
# step 1: 安装必要的一些系统工具
yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3
sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
# Step 4: 更新并安装Docker-CE
yum makecache fast
yum -y install docker-ce
# Step 4: 开启Docker服务
systemctl enable docker
systemctl start docker

echo "切换 shell，手动执行: chsh -s \$(which fish)"
echo "安装 Vim 插件，手动执行: :PlugInstall"
echo "Vim 启用主题，安装插件后，去掉.vimrc注释符号: colorscheme darcula"